﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VICC_PRNDEF
    {
        VICC_PCTYPE VICC_PCTYPE;
    }
    public partial class VICC_PRNDEF
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

  
                    dwReturn["MANDANT"] = "00";
                    dwReturn["ROWNID"] = "4095";
                    dwReturn["COMPANY"] = "";
                    dwReturn["USERID"] = "";
                    dwReturn["KUNDNR"] = "00000037";
                    dwReturn["PRNAME"] = "W37                 ";
                    dwReturn["PRPROG"] = "";
                    dwReturn["PRCOND"] = "1";
                    dwReturn["PRDES"] = "";
                    dwReturn["PRVER"] = "0";
                    dwReturn["PRLX"] = "0";
                    dwReturn["PRLY"] = "0";
                    dwReturn["PRRX"] = "0";
                    dwReturn["PRRY"] = "0";
                    dwReturn["PRLTHICK"] = "";
                    dwReturn["PRCTYPE"] = "A    ";
                    dwReturn["PRCTYPDES"] = "    ";
                    dwReturn["PRFONT"] = "        ";
                    dwReturn["PRFONTSIZE"] = "40";
                    dwReturn["PRCONTENT"] = "ART:";
                    dwReturn["PRCONTDES"] = "";
                    dwReturn["PRAENDAT"] = "20140626"; 
               
        } 
        public void InsertICC_PRNDEF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {

                default:
                    or1.CommandText = "INSERT INTO ICC_PRNDEF ( MANDANT,ROWNID,COMPANY,USERID,KUNDNR,PRNAME,PRPROG,PRCOND,PRDES,PRVER,PRLX,PRLY,PRRX,PRRY,PRLTHICK,PRCTYPE,PRCTYPDES,PRFONT,PRFONTSIZE,PRCONTENT,PRCONTDES,PRAENDAT)"
                   + " VALUES (:MANDANT:,:ROWNID:,:COMPANY:,:USERID:,:KUNDNR:,:PRNAME:,:PRPROG:,:PRCOND:,:PRDES:,:PRVER:,:PRLX:,:PRLY:,:PRRX:,:PRRY:,:PRLTHICK:,:PRCTYPE:,:PRCTYPDES:,:PRFONT:,:PRFONTSIZE:,:PRCONTENT:,:PRCONTDES:,:PRAENDAT:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }

            Connect2Proxy(or1);
        }
        public void DeleteICC_PRNDEF(DataRow dwData, int option = 1)
        {

            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM ICC_PRNDEF  WHERE MANDANT=:MANDANT: AND ROWNID=:ROWNID:"; 
                    break;
                case 2:
                    or1.CommandText = "DELETE FROM ICC_PRNDEF  WHERE MANDANT=:MANDANT: AND KUNDNR=:KUNDNR:"; 
                    break;
                case 3:
                    or1.CommandText = "DELETE FROM ICC_PRNDEF  WHERE MANDANT=:MANDANT: AND KUNDNR=:KUNDNR: AND PRNAME=:PRNAME:"; 
                    break;
                default:
                    break;
            }
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);
        }
        public DataSet QueryICC_PRNDEF(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ICC_PRNDEF WHERE MANDANT=:MANDANT  AND ROWNID=:ROWNID"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("ROWNID", OracleType.NVarChar).Value = dwData["ROWNID"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT * FROM ICC_PRNDEF "
                    + " WHERE MANDANT=:MANDANT AND KUNDNR=:KUNDNR AND TRIM(PRNAME)=:PRNAME"
                    + " ORDER BY TO_NUMBER(PRLY),TO_NUMBER(PRLX)"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("KUNDNR", OracleType.NVarChar).Value = dwData["KUNDNR"].ToString();
                    or1.Parameters.Add("PRNAME", OracleType.NVarChar).Value = dwData["PRNAME"].ToString().Trim();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_PRNDEF";
            Return = Result;
            return Return;
        }
        public void UpdateICC_PRNDEF(DataRow dwData, int option = 0)
        {
            OracleCommand or1;
            DataSet Result = new DataSet();
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_PRNDEF SET MANDANT=:MANDANT:,ROWNID=:ROWNID:,COMPANY=:COMPANY:,USERID=:USERID:,KUNDNR=:KUNDNR:,PRNAME=:PRNAME:,PRPROG=:PRPROG:,PRCOND=:PRCOND:,PRDES=:PRDES:,PRVER=:PRVER:,PRLX=:PRLX:,PRLY=:PRLY:,PRRX=:PRRX:,PRRY=:PRRY:,PRLTHICK=:PRLTHICK:,PRCTYPE=:PRCTYPE:,PRCTYPDES=:PRCTYPDES:,PRFONT=:PRFONT:,PRFONTSIZE=:PRFONTSIZE:,PRCONTENT=:PRCONTENT:,PRCONTDES=:PRCONTDES:,PRAENDAT=:PRAENDAT:"
                    + " WHERE    MANDANT=:MANDANT: AND ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
